#import "WWSimpleMovieViewIBInspector.h"
#import "WWSimpleMovieView.h"
#import "aspectRatios.h"

@implementation WWSimpleMovieViewIBInspector

- init 
{
   char buf[MAXPATHLEN + 1];
   id bundle;
    
   [super init];
    
   bundle = [NXBundle bundleForClass:[self class]];
   [bundle getPath:buf forResource:"WWSimpleMovieViewIBInspector" ofType:"nib"];
   [NXApp loadNibFile:buf owner:self withNames:NO fromZone:[self zone]];
   [self revert:nil];

   return self;
}

- revert:sender 
{ 
   [theColor setColor:[object backgroundColor]];
   [alphaSlider setFloatValue:[object alpha]];
   if ([object drawCorrectly])
   {  [alphaSlider setEnabled:YES];
   }
   else
   {  if ( [object frameCount])
      {  [alphaSlider setEnabled:NO];
      }
      else
      {  [alphaSlider setEnabled:YES];
      }
   }
   if ([object archiveImageData])
   {  [theImage setStringValue:""];
   }
   else
   {  [theImage setStringValue:[[object image] name]];
   }

   if ([object archiveMovieData])
   {  [theImage setStringValue:""];
   }
   else
   {  [theMovie setStringValue:[[object movieImage] name]];
   }

   [drawCorrectlySwitch setIntValue:[object drawCorrectly]];
   [aspectRatioMatrix selectCellWithTag:[object aspectRatioType]];
   [horizontalLayoutMatrix selectCellWithTag:[object horizontalLayoutType]];
   [verticalLayoutMatrix selectCellWithTag:[object verticalLayoutType]];
   [customAspectRatioText setFloatValue:[object aspectRatio]];
   [customAspectRatioText setEnabled:([object aspectRatioType] == WW_ASPECT_CUSTOM)];
   [scaleSwitch setIntValue:(int)[(WWSimpleMovieView *)object scaleToFit]];
   [imageUnderSwitch setIntValue:[object imageUnder]];
   [rotateTo setFloatValue:[object frameAngle]];
   [borderTypeMatrix selectCellWithTag:[object borderType]];
   [stationaryBehaviorMatrix selectCellWithTag:[object stationaryBehavior]];
   [loopSwitch setIntValue:[object loop]];
   [archiveMovieDataSwitch setIntValue:[object archiveMovieData]];
   [archiveImageDataSwitch setIntValue:[object archiveImageData]];

   [fpsText setFloatValue:[object fps]];
 
   return self;
}

- sizeToImage:s { [object sizeToImage:s]; [self revert:nil]; return [super ok:s]; }
- takeColor_:s	{ [object setBackgroundColor:[theColor color]]; [self revert:nil]; return [super ok:s]; }
- setAlpha_:s	{ [object setBackgroundAlpha:[s floatValue]]; [self revert:nil]; return [super ok:s]; }
- setImage_:s	{ [object setImageFile:(char *)[s stringValue]]; [self revert:nil]; return [super ok:s]; }
- removeImage_:s { [object removeImage:nil]; [self revert:nil]; return [super ok:s]; }
- removeMovie_:s { [object removeMovie:nil]; [self revert:nil]; return [super ok:s]; }
- setMovie_:s	{ [object setAnimDir:(char *)[s stringValue]]; [self revert:nil]; return [super ok:s]; }
- setAspectRatio_:s	{ [object setAspectRatio:s]; [self revert:nil]; return [super ok:s]; }
- setImageUnder_:s	{ [object setImageUnder:[s intValue]]; [self revert:nil]; return [super ok:s]; }
- setScale_:s	{ [object setScaleToFit:[s intValue]]; [self revert:nil]; return [super ok:s]; }
- setAspectRatioFromMatrix_:s	{ [object setAspectRatioFromMatrix:s]; [self revert:nil]; return [super ok:s]; }
- setHorizontalLayoutFromMatrix_:s	{ [object setHorizontalLayoutFromMatrix:s]; [self revert:nil]; return [super ok:s]; }
- setBorderTypeFromMatrix_:s	{ [object setBorderType:[[s selectedCell] tag]]; [self revert:nil]; return [super ok:s]; }
- setVerticalLayoutFromMatrix_:s	{ [object setVerticalLayoutFromMatrix:s]; [self revert:nil]; return [super ok:s]; }
- setFPS_:s	{ [object setFPS:[s floatValue]]; [self revert:nil]; return [super ok:s]; }
- setStationaryBehaviorFromMatrix_:s	{ [object setStationaryBehaviorFromMatrix:s]; [self revert:nil]; return [super ok:s]; }
- setLoop_:s	{ [object setLoop:[s intValue]]; [self revert:nil]; return [super ok:s]; }
- setArchiveMovieData_:s	{ [object setArchiveMovieData:[s intValue]]; [self revert:nil]; return [super ok:s]; }
- setArchiveImageData_:s	{ [object setArchiveImageData:[s intValue]]; [self revert:nil]; return [super ok:s]; }
- setDrawCorrectly_:s	{ [object setDrawCorrectly:[s intValue]]; [self revert:nil]; return [super ok:s]; }

- rotateTo_:s { [object rotateTo:[s floatValue]];  [object display]; [self revert:nil]; return [super ok:s]; }

- sizeToImage_:s { [object sizeToImage:s];  [object display]; [self revert:nil]; return [super ok:s]; }
- sizeToMovie_:s { [object sizeToMovie:s];  [object display]; [self revert:nil]; return [super ok:s]; }

- (BOOL)wantsButtons	{ return NO; }
@end

